﻿@page "/PivotGridLargeDataBase"
@inject IContosoRetailDataProvider ContosoRetailContext
@layout DataProviderAccessArea<IContosoRetailDataProvider>

<div class="demo-description">
    <h2>Large Data Source</h2>
    <p>
        This demo shows the performance of the <a class="helplink" target="_blank" href="https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxPivotGrid-1">Pivot Grid</a> when it is bound to a dataset that contains a million rows. Experiment with navigating between the pages and sorting the data to experience the responsiveness of the pivot grid in this situation. The pager is enabled by setting the Pivot Grid's <a class="helplink" target="_blank" href="https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxPivotGrid.ShowPager">ShowPager</a> and <a class="helplink" target="_blank" href="https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxPivotGrid.PageSize">PageSize</a> properties.
    </p>
    <p>
        In this example, Entity Framework Core (version 3.0) supplies the Pivot Grid with an IQueryable&lt;T&gt; source.
    </p>
</div>
@if (largeDataSource == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <DxPivotGrid Data="@largeDataSource"
                 ShowPager="true"
                 PageSize="10"
                 CssClass="mw-1100">
        <DxPivotGridField Field="@nameof(Sale.StoreName)" Caption="Store" Area="PivotGridFieldArea.Row" />
        <DxPivotGridField Field="@nameof(Sale.DateKey)" GroupInterval="PivotGridGroupInterval.Year" Caption="Year" Area="PivotGridFieldArea.Column" />
        <DxPivotGridField Field="@nameof(Sale.SalesAmount)" Caption="Amount" Area="PivotGridFieldArea.Data" SummaryType="PivotGridSummaryType.Sum">
            <DataTemplate>@string.Format("{0:c0}", context)</DataTemplate>
        </DxPivotGridField>
        <DxPivotGridField Field="@nameof(Sale.Id)" Caption="Count" Area="PivotGridFieldArea.Data" SummaryType="PivotGridSummaryType.Count">
            <DataTemplate>@string.Format("{0:n0}", context)</DataTemplate>
        </DxPivotGridField>
    </DxPivotGrid>
}
<CodeSnippet_Pivot_LargeDataSource/>
@code {

    IEnumerable<Sale> largeDataSource;

    protected override async Task OnInitializedAsync()
    {
        largeDataSource = await ContosoRetailContext.GetSalesAsync();
    }
}
